﻿using FishSimulation.Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;

namespace FishSimulation.Converters
{
    [ValueConversion(typeof(List<ModelBase>), typeof(String))]
    public class ListToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType,
            object parameter, CultureInfo culture)
        {
            var list = value as IEnumerable<ModelBase>;
            if (list != null)
            {
                return list.Join(",");
            }

            return Binding.DoNothing;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Binding.DoNothing;
        }
    }
}
